from page.mainpage import MainPage


class SchoolManagement(MainPage):

    def goto_schoolmanagement(self):
        """
        点击进入侧导航栏排列第一的县级的学校管理页面
        :return:
        """
        self.click("css", '#app > div > section > div > div:nth-child(2) > section > ul > li:nth-child(1)')

    def locate_addschool_button(self):
        """
        定位新增学校按钮
        :return:
        """
        self.locate("css","div.options > div.actionsgroup > button:nth-child(3)")

    def add_school(self, school_name, school_account, password):
        """
        点击新增学校
        输入学校名称
        输入账号
        输入密码
        点击提交
        :param school_name: 学校名称
        :param school_account: 学校账号
        :param password: 密码
        :return:
        """
        self.click("css", "div.options > div.actionsgroup > button:nth-child(3)")
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(1) > div > input', school_name)
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(2) > div > input', school_account)
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(3) > div > input', password)
        self.click_submit()

    def get_num1_schoolname(self):
        """

        :return: 获取排在学校列表第一个的学校名称
        """
        return self.get_text("css", "div.el-table__body-wrapper.is-scrolling-none > table > tbody > tr:nth-child(1) > td.el-table_1_column_1.is-center")

    def get_num1_schoolaccount(self):
        """

        :return:获取排在学校列表第一个的学校账号
        """
        return self.get_text("css", "div.el-table__body-wrapper.is-scrolling-none > table > tbody > tr:nth-child(1) > td.el-table_1_column_2.is-center")

    def edit_school(self, school_name, password):
        """
        点击编辑列表第一个学校
        输入学校名称
        输入密码
        点击提交
        :param school_name:学校名称
        :param password: 密码
        :return:
        """
        self.click("css",
                   "div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_1_column_6.is-center > div > button:nth-child(1)")
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(1) > div > input', school_name)
        self.send_keys("css", 'div.main-content > section > section > div:nth-child(3) > div > input', password)
        self.click_submit()

    def delete_num1_school(self):
        """
        点击删除列表第一个学校
        :return:
        """
        self.click("css",
                   'div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_1_column_6.is-center > div > button:nth-child(2)')

    def goto_num1_schooldetails(self):
        """
        点击进入第一个学校详情
        :return:
        """
        self.click("css",
                   "div.el-table__fixed-body-wrapper > table > tbody > tr > td.el-table_1_column_6.is-center > div > button:nth-child(3)")

    def get_addclass_text(self):
        """

        :return:获取新增班级文本
        """
        return self.get_text("css", "div.options > div.actionsgroup > button:nth-child(3)")
